<HTML><HEAD><TITLE>sorted(?List, ?Sorted, ?Positions)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">library(fd_global)</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>sorted(?List, ?Sorted, ?Positions)</H1>
Sorted is a sorted permutation (described by Positions) of List
<DL>
<DT><EM>List</EM></DT>
<DD>List of domain variables or integers
</DD>
<DT><EM>Sorted</EM></DT>
<DD>List of domain variables or integers
</DD>
<DT><EM>Positions</EM></DT>
<DD>List of domain variables or integers
</DD>
</DL>
<H2>Description</H2>
    Declaratively:  Sorted is a sorted permutation of List.  Positions
    is a list whose elements range from 1 to N (where N is the length
    of the lists) indicating the position of each unsorted list
    element within the sorted list.  The positions are all different. 
    The three lists are constrained to have the same length.
<P>
    Operationally:  the elements in all three lists are constrained
    such that their domains are consistent with the declarative
    meaning.
<P>
    Two of the three arguments can be uninstantiated or partial lists
    at call time.
<P>
    Any input variables which do not already have finite bounds will
    be given default bounds of -10000000 to 10000000.
    
<H3>Modes and Determinism</H3><UL>
<LI>sorted(+, ?, ?)
<LI>sorted(?, +, ?)
<LI>sorted(?, ?, +)
</UL>
<H2>Examples</H2>
<PRE>
    ?- length(Xs,4), Xs::0..100, sorted(Xs,Ys,Ps), Xs = [8,20|_].

    Xs = [8, 20, _346{[0..100]}, _359{[0..100]}]
    Ys = [_445{[0..8]}, _427{[0..20]}, _537{[8..100]}, _635{[20..100]}]
    Ps = [_882{[1..3]}, _895{[2..4]}, _908{[1..4]}, _921{[1..4]}]
    </PRE>
<H2>See Also</H2>
<A HREF="../../lib/fd_global/sorted-2.html">sorted / 2</A>, <A HREF="../../lib/fd_global/ordered-2.html">ordered / 2</A>
</BODY></HTML>
